-
-
Notifications
You must be signed in to change notification settings - Fork 41
misc: Optimize flash and memory usage. #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
FYI @pillo79 @pennam for some reason enabling log level=4 (debug for everything) causes a hardfault on Portenta-H7. It shouldn't be a stack overflow issue, but I tried increasing all stacks anyway and it doesn't help. That said, it is very convenient and I have been using it locally, instead of adding debug options manually to conf files, so I will get it fixed somehow and let you know. |
0df6fb2 to
46d57bd
Compare
|
Actually, it turns out that it's just some log thread overflow, fixable by increasing stack sizes. However,, I decided to Not enable debug logs globally, because we don't really have extra memory for that and it makes it much harder to see the debug log you're looking for. |
46d57bd to
0cf7454
Compare
Add debug config fragment to easily build debug images. Usage: ./extra/build.sh <board> --debug The build includes extra/debug.conf which enables: - Debug mode with assertions and verbose output - Debug-level logging (level 4) - Stack overflow detection - Thread monitoring - Debug optimizations (-Og) - Enable shell. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
0cf7454 to
ccd08d2
Compare
The created sketch log structures depends on the config: CONFIG_LOG (IMMEDIATE/DEFERRED): creates log_const_sketch struct. CONFIG_LOG_RUNTIME_FILTERING (implied by CONFIG_SHELL): creates log_dynamic_sketch struct. CONFIG_LOG_MODE_IMMEDIATE + CONFIG_SHELL: creates both. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Replace the libc's malloc, free etc.. with wrappers that redirect memory allocation Zephyr's kernel heap functions (k_malloc/k_free). Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This saves about 70KBs FLASH and ~47KBs RAM. The saved memory is used to increase mbedtls heap to support cert loading, and the remaining added to main heap. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
ccd08d2 to
3fed70a
Compare
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
3fed70a to
5d1e8f5
Compare
This PR optimizes flash and memory usage, saving up to ~80KBs flash and ~50KBs RAM on some boards, by disabling the shell for production builds, CPP and using a unified heap for Zephyr and sketches. The saved memory is used to increase mbedtls heap to support cert loading, and the remaining added to main heap. For Portenta, ~100KBs should be available to user sketches.
Changes:
To build debug images use:
./extra/build.sh <board> --debugThe build includes extra/debug.conf which enables: